#!/usr/bin/env python
# -*- coding: utf-8 -*-
# author:Charles.chen
# createDate:2017/9/14
# Title: 传感器数据
# Tip:
from app.model import SensorData

# 根据传感器编号获得最新一条的数据
def getLastDataBySensorNo(sensorNo=None):
    return SensorData.select().where(SensorData.sensor_no==sensorNo).order(SensorData.created_time.desc).limit(1).execute()

# 根据传感器编号获取历史数据
def getHistoryBySensorNo(sensorNo=None,limit=200):

    res = SensorData.select().where(SensorData.sensor_no==sensorNo).order(SensorData.created_time.desc).limit(limit).execute()

    return res
    pass


if __name__ == '__main__':
    pass